package cn.gz.demo.ui.xd;


import android.os.Bundle;

import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.Fragment;

import com.google.android.material.tabs.TabLayout;

import java.util.ArrayList;
import java.util.List;

import cn.gz.demo.R;
import cn.gz.demo.adapter.FragmentTabAdapter;
import cn.gz.demo.databinding.TwoXdBinding;
import cn.gz.demo.ui.base.BaseActivity;
import cn.gz.demo.ui.tab_fragment.FoundFragment;
import cn.gz.demo.ui.tab_fragment.MeFragment;
import cn.gz.demo.ui.tab_fragment.MessageFrament;

public class TwoXdActivity extends BaseActivity {
    private TwoXdBinding binding;
    private FragmentTabAdapter adapter;
    public List<Fragment> fragments = new ArrayList<Fragment>();
    private List<String> titles = new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = DataBindingUtil.setContentView(this, R.layout.activity_two_xd);

        initView();
    }

    private void initView() {
        titles.clear();
        titles.add("发现");
        titles.add("发现");
        titles.add("发现");
        titles.add("发现");

        fragments.add(new XdFrament());
        fragments.add(new FoundFragment());
        fragments.add(new MeFragment());
        fragments.add(new MessageFrament());
        adapter = new FragmentTabAdapter(getSupportFragmentManager(), fragments, titles);
        binding.tabViewpager.setAdapter(adapter);

        binding.tabTablayout.setupWithViewPager(binding.tabViewpager);
        binding.tabTablayout.setTabMode(TabLayout.MODE_FIXED);
    }
}
